home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Personal Computer World 2009 February
/
PCWFEB09.iso
/
Software
/
Resources
/
Chat & Communication
/
Digsby build 37
/
digsby_setup.exe
/
lib
/
xml
/
dom
/
domreg.pyo
(
.txt
)
< prev
next >
Wrap
Python Compiled Bytecode
|
2008-10-13
|
2KB
|
81 lines
# Source Generated with Decompyle++
# File: in.pyo (Python 2.5)
from xml.dom.minicompat import *
well_known_implementations = {
'minidom': 'xml.dom.minidom',
'4DOM': 'xml.dom.DOMImplementation' }
registered = { }
def registerDOMImplementation(name, factory):
registered[name] = factory
def _good_enough(dom, features):
for f, v in features:
if not dom.hasFeature(f, v):
return 0
continue
return 1
def getDOMImplementation(name = None, features = ()):
import os as os
creator = None
mod = well_known_implementations.get(name)
if mod:
mod = __import__(mod, { }, { }, [
'getDOMImplementation'])
return mod.getDOMImplementation()
elif name:
return registered[name]()
elif os.environ.has_key('PYTHON_DOM'):
return getDOMImplementation(name = os.environ['PYTHON_DOM'])
if isinstance(features, StringTypes):
features = _parse_feature_string(features)
for creator in registered.values():
dom = creator()
if _good_enough(dom, features):
return dom
continue
for creator in well_known_implementations.keys():
try:
dom = getDOMImplementation(name = creator)
except StandardError:
continue
if _good_enough(dom, features):
return dom
continue
raise ImportError, 'no suitable DOM implementation found'
def _parse_feature_string(s):
features = []
parts = s.split()
i = 0
length = len(parts)
while i < length:
feature = parts[i]
if feature[0] in '0123456789':
raise ValueError, 'bad feature name: %r' % (feature,)
i = i + 1
version = None
if i < length:
v = parts[i]
if v[0] in '0123456789':
i = i + 1
version = v
features.append((feature, version))
return tuple(features)